<?php
$currency = Yii::app()->user->getState('currency');
$layout_asset = GxcHelpers::publishAsset(Yii::getPathOfAlias('common.layouts.default.assets'));
?>
<fieldset>
    <legend>Payment method</legend>
    <div class="form_fieldset">
        <?php
        if (strtoupper($currency) == "VND") {
            echo '<div class="row_payment">';
            echo $form->radioButton($model, 'payment_method', array('value' => 'vtc_payment', 'checked' => 'checked', 'uncheckValue' => null));
            echo '<b>Thanh toán VTC Pay ( thẻ ATM/Visa/Mastercard )</b><br>
                      <p style="padding-left:15px; color: #777;">Thu 2,000VND khoản phí khi thanh toán bằng VTC Pay.</p>';
            echo '</div><div class="row_payment">';
            echo $form->radioButton($model, 'payment_method', array('value' => 'oncome_nd', 'uncheckValue' => null));
            echo '<b>Thanh toán OnPay ( thẻ ATM/Visa/Mastercard )</b><br>
                      <p style="padding-left:15px; color: #777;">Thu 2,000VND khoản phí khi thanh toán bằng Onpay nội địa.</p>';
            echo '</div>';
            echo $form->hiddenField($model, 'payment_currency', array('value' => 'VND'));
        } else {
            if (strtoupper($currency) == "AUD") {
                ?>
                <div class="row_payment">
                    <table>
                        <tr>
                            <td valign="top" style="padding-top: 5px;"><?php echo $form->radioButton($model, 'payment_method', array('value' => 'commonwealth', 'checked' => 'checked', 'uncheckValue' => null)); ?></td>
                            <td valign="top" style="padding-right: 5px;"><?php echo '<img src="' . $layout_asset . '/images/icon-commonwealth.png" />'; ?></td>
                            <td style="color: #777; border-left: 1px solid #ccc;padding-left: 5px;">
                                Khách ở Úc nên sử dụng chuyển khoản Commonwealth bank:<br>
                                * <b>Phuong V Bui</b> (Name)<br>
                                * <b>063-138</b> (BSB)<br>
                                * <b>01-038-0196</b> (Account number)
                            </td>
                        </tr>

                    </table>
                </div>
                <?php
            }
            ?>
            <div class="row_payment">
                <table>
                    <tr>
                        <td><?php
                            if (strtoupper($currency) == "USD") {
                                echo $form->radioButton($model, 'payment_method', array('value' => 'oncome', 'checked' => 'checked', 'uncheckValue' => null));
                            } else {
                                echo $form->radioButton($model, 'payment_method', array('value' => 'oncome', 'uncheckValue' => null));
                            }
                            ?>
                        </td>
                        <td><?php
                            echo '<img src="' . $layout_asset . '/images/icon-visa.png" />'
                            . '&nbsp;<img src="' . $layout_asset . '/images/icon-mastercard.png" />'
                            . '&nbsp;<img src="' . $layout_asset . '/images/icon-amex.png" />';
                            ?></td>
                        <td>by <b>OnePAY</b></td>
                        <td class="note">( phí thanh toán: $0.29 )</td>
                    </tr>
                </table>
            </div>
            <div class="row_payment">
                <table>
                    <tr>
                        <td><?php echo $form->radioButton($model, 'payment_method', array('value' => 'paypal', 'uncheckValue' => null)); ?></td>
                        <td><?php echo '<img src="' . $layout_asset . '/images/icon-paypal.png" />'; ?></td>
                        <td class="note">( phí thanh toán: $0.29 )</td>
                    </tr>
                </table>
            </div>
            <div class="row_payment">
                <table>
                    <tr>
                        <td><?php echo $form->radioButton($model, 'payment_method', array('value' => 'changecard', 'uncheckValue' => null)); ?></td>
                        <td><b>Đổi Thẻ</b></td>
                        <td class="note"></td>
                    </tr>

                </table>
            </div>
            <?php
            $listCurr = array($currency => $currency);
            echo '</div>';
            echo '<br><div>Currency To Checkout: ' . $form->dropDownList($model, 'payment_currency', $listCurr, array('id' => 'select-sale_currency')) . '</di>';
        }
        ?>

    </div>
</fieldset>

<script type="text/javascript">
    $(document).ready(function() {
        $(".form_fieldset input[type='radio']").click(function() {
            //alert("select change");
            $('#select-sale_currency').empty();
            selectVal = $(this).val();
            if ((selectVal == 'oncome') || (selectVal == 'changecard')) {
                $('#select-sale_currency').append('<option value="USD" selected="selected">USD</option>');
            }
            if (selectVal == 'commonwealth') {
                $('#select-sale_currency').append('<option value="AUD" selected="selected">AUD</option>');
            }
            if (selectVal == 'paypal') {
                $('#select-sale_currency').append('<option value="AUD" selected="selected">AUD</option><option value="USD">USD</option>');
            }
        });
    });

</script>
